using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace AsposeQuickStart
{
    public static class Settings
    {
        //set paths to store files
        public static string FilePath = Environment.CurrentDirectory + @"\Data\Files\";
        public static string LogPath = Environment.CurrentDirectory + @"\Data\Log\Exceptions.log";

        //public static string FilePath = "Data\\Files";
        //public static string LogPath = "Data\\Log";

        //remove the old log file on project initialization
        public static void InitializeLog()
        {
            if(File.Exists(LogPath))
                 File.Delete(LogPath);
        }

        //log an exception in the log file
        public static void LogException(Exception ex)
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendLine(DateTime.Now.ToString());
            stringBuilder.AppendLine(ex.Message);
            stringBuilder.AppendLine(ex.StackTrace);
            stringBuilder.AppendLine("---------------------------------------------");
            if (File.Exists(LogPath))
                File.AppendAllText(LogPath, stringBuilder.ToString());
            else
                File.WriteAllText(LogPath, stringBuilder.ToString());
        }

        //wait for user input and then exit program
        public static void ExitProgram()
        {
            Console.WriteLine("\n\n");
            Console.WriteLine("Press any key to exit the program...");
            Console.ReadLine();
        }
    }
}
